package com.yc.cloud.openai.portal.config;

import java.nio.file.Paths;

import org.springframework.stereotype.Component;

import com.yc.cloud.common.basic.utils.PathUtils;

import cn.hutool.core.io.FileUtil;
import lombok.val;

@Component
public class PathManager {

    private final PathUtils pathUtils;

    public PathManager(PathUtils pathUtils) {
        this.pathUtils = pathUtils;
    }

    /**
     * 获取 TTS 文件夹路径
     *
     * @return TTS 文件夹路径
     */
    public String getTTSFolder() {
        val folder = Paths.get(pathUtils.getBasePath(), "tts").toString();
        if (!FileUtil.exist(folder)) {
            FileUtil.mkdir(folder);
        }
        return folder;
    }

    /**
     * 获取 水印处理后视频 文件夹路径
     *
     * @return TTS 文件夹路径
     */
    public String getWaterVideoFolder() {
        val folder = Paths.get(pathUtils.getBasePath(), "watervideo").toString();
        if (!FileUtil.exist(folder)) {
            FileUtil.mkdir(folder);
        }
        return folder;
    }


    /**
     * 获取 GPT 文件夹路径
     *
     * @return GPT 文件夹路径
     */
    public String getGPTFolder() {
        val folder = Paths.get(pathUtils.getBasePath(), "gpt").toString();
        if (!FileUtil.exist(folder)) {
            FileUtil.mkdir(folder);
        }
        return folder;
    }
}
